<template>
  <div id="app">
    <router-view name='index'></router-view>
    <router-view name='others'></router-view>
    <el-amap vid="amap" :plugin="plugin" class="amap-demo"></el-amap>
    <router-view></router-view>
    <!-- <foot></foot> -->
  </div>
</template>

<script>
// import foot from './components/Footer';
export default {
  name: 'app',
  data() {
    let self = this;
    return {
      positions: {
        lng: '',
        lat: '',
        address: '',
        loaded: false
      },
      center: [121.59996, 31.197646],
      plugin: [{
        pName: 'Geolocation',
        events: {
          init(o) {
            // o 是高德地图定位插件实例
            o.getCurrentPosition((status, result) => {
              // console.log(result);
              if (result && result.position) {
                self.str = result.formattedAddress;
                self.positions.address = self.str.substring(self.str.indexOf('市') + 1);
                self.positions.lng = result.position.lng;
                self.positions.lat = result.position.lat;
                self.positions.loaded = true;
                self.$nextTick();
                // 把获取的数据提交到 store 的数据中，以便其他单文件组件使用
                self.$store.commit('POSITION', self.positions);
                // console.log(self.positions);
                sessionStorage.setItem('id', JSON.stringify(self.positions));
              }
            });
          }
        }
      }]
    };
  }
  // components: { foot }
}
</script>

<style lang='scss'>
@import '../static/hotcss/px2rem.scss';
@import './common/css/resert.scss';
#app {
  height: 100%;
  .amap-demo {
    display: none;
  }
}
</style>
